package cn.edu.zut.service.impl;

import cn.edu.zut.dao.IReaderDao;
import cn.edu.zut.domin.Reader;
import cn.edu.zut.service.IReaderService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class ReaderServiceImpl implements IReaderService {

    @Autowired
    IReaderDao iReaderDao;
    public List<Reader> findAll(int page, int size) throws Exception
    {
        PageHelper.startPage(page,size);

        List<Reader> readers=iReaderDao.findAll();
        System.out.println("");
        return readers;
    }

    /**
     * 查询一本书
     * @return
     * @throws Exception
     */
    public List<Reader> findReaderById(String id) throws Exception
    {
        List<Reader> readers=iReaderDao.findReaderById(id);
        return readers;
    }


    public void saveReader(Reader reader) throws Exception
    {
        iReaderDao.saveReader(reader);
    }
    public void deleteReader(String id) throws Exception
    {
        iReaderDao.deleteReader(id);
    }


    public void updateReader(Reader reader) throws Exception
    {
        iReaderDao.updateReader(reader);
    }

    public List<Reader> selectBookLendInfoByReaderId(String Id)
    {
        List<Reader> readers=iReaderDao.selectBookLendInfoByReaderId(Id);
        return readers;
    }


    public List<Reader> selectAllBookLendInfoByReaderId()
    {
        List<Reader> readers=iReaderDao.selectAllBookLendInfoByReaderId();

        return readers;
    }
    public List<Reader> findReaderByName(String userName)
    {
        List<Reader> readers=iReaderDao.findReaderByUserName(userName);
        return readers;

    }

    @Override
    public List<Reader> findByReaderTel(String tel) {
        List<Reader> readers=iReaderDao.findByReaderTel(tel);
        return readers;
    }
    public List<Reader> findReaderByNameMOHU(String name)
    {
        List<Reader> readers=iReaderDao.findReaderByNameMOHU(name);
        return readers;
    }

    @Override
    public Reader findReaderById1(String id) {
        return iReaderDao.findReaderById1(id);
    }
}
